home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 27
/
027.d81
/
t.prebase boot
< prev
next >
Wrap
Text File
|
2022-08-26
|
6KB
|
392 lines
PREBASE
by
Michael Leidel
COMMODORE POWER/PLAY MAGAZINE
August/September, 1986
**************************************
NOTE: You must copy PREBASE, PASS2,
and PREBASE BOOT to another disk
before using this program.
**************************************
THE BIG PICTURE......
If you've been used to writing
programs in languages like FORTRAN and
Pascal, PREBASE might make writing
BASIC programs easier for you. PREBASE
is a BASIC preprocessor that allows
you to write programs that use
structured control keywords like
WHILE-ENDWHILE, LOOP-ENDLOOP, or
LOOP-UNTIL that you've known from
other high-level languages.
PREBASE also allows the use of
English labels for branching instead
of line numbers, provides a directive
for including prewritten library
routines, and removes all REM
statements and extra spaces.
Once you have created a PREBASE
program file, Leidlel's two programs
("PREBASE" and "PASS 2") will convert
the PREBASE source file to a normal
BASIC program.
We have included a sample PREBASE
program, "PREBASE TEST". To see it,
run PREBASE, and enter its name as the
program you want converted.
WRITING PROGRAMS IN PREBASE
Writing PREBASE programs is similar
to writing BASIC programs-- there are
only a few more rules to keep in mind.
-- Line numbers should only be used
for sequencing lines, never after a
THEN, GOTO, or GOSUB. Instead,
English labels should follow a GOTO or
GOSUB; however, labels should never
follow a THEN, although other BASIC
statements may.
-- The target label should be the only
entry on the line. It can be composed
of any combination of regular or
special characters and must be unique.
Resequencing line numbers will not
affect program control logic.
-- Nothing must come before or after a
structured control construct on a
line. The conditional following WHILE
or UNTIL must be preceded by one
space; nothing must follow the
conditional.
-- Nesting may not exceed ten levels.
WHILE-ENDWHILE provides a condition
check at the beginning of a loop,
LOOP-UNTIL a condition check at the
end of a loop. LOOP-ENDLOOP provides
a closed loop that must be exited by a
GOTO.
-- PREBASE will merge in other PREBASE
files during its processing cycle. To
use this "include" directive feature,
enclose the name in quotes and then in
square brackets. For example,
100 ["filename"]
will merge in the program file at line
100 of the program using this
directive.
Nothing else may precede or follow
this directive on a line. The file
used in the directive cannot itself
contain a directive of this type.
-- Any line that is not a label,
structured control construct,
"include" directive, or REM statement
must begin with a period. This
distinguishes a regular line from a
line needing special attention.
-- A shifted space may be used instead
of a period to begin a regular line.
However, if you re-edit a line, the
shifted space will be removed. Each
time the line is edited, the space
must be replaced. A line beginning
with a period does not require this
attention.
-- In the translation process, PREBASE
removes all REM statements and extra
spaces, converts all structured
constructs into regular BASIC
statements, makes branch labels
correspond with line numbers, and
integrates library routines that were
merged into a normal BASIC file. The
translated program is written to the
disk with the name of the original
PREBASE file plus a ".BAS" extention
that marks it as a file that was once
a PREBASE file.
-- PREBASE will not check normal BASIC
syntax or logic errors, but will
indicate certain errors relevant to
its special features. If these kinds
of syntax errors are found, the errors
are listed and the final program is
not produced.
USING PREBASE
The first of the two programs,
"PREBASE" requests the date, the name
of the PREBASE program to be
translated, its beginning line number,
and the increment for the BASIC output
file. It then parses through both the
PREBASE source file and any "included"
library files to make a file called
SYMTBL on disk.
-- If you have the same name for two
different branch labels, you will get
a DUPLICATE LABEL error, and the
program will not execute the second
phase. To fix, change one of the
labels.
The second part of the program,
PASS 2, uses the information in the
SYMTBL file to construct a normal
BASIC program. The size of the
BASIC program will depend on how many
REM statements and spaces were removed
and how many "include" directives were
used.
If PASS 2 encounters errors, they,
along with the line at which they
occur, are displayed at the end of
processing and the BASIC program is
not created. If it finds ten errors,
PASS 2 will stop at that point and
list them.
POSSIBLE ERRORS
-- Incorrect formation of a construct
or label:
LOOP ERROR
ENDLOOP ERROR
INVALID LABEL
UNTIL ERROR
ENDWHILE ERROR
-- Missing part of a structured
construct:
NO MATCHING LOOP
MISSING LOOP
NO MATCHING ENDWHILE
NO MATCHING WHILE
-- Reference to a nonexistent label:
UNDEF LABEL
PASS 2 may crash if a line does not
begin with a REM, a structured
construct, an "include" directive, or
a period. If this happens and you
want to examine the error list, GOTO
8020.
Examining the SYMTBL file is also
helpful. To do this, type in
immediate mode:
FORX=1TOLC:?LBL$(X),NUM$(X):NEXT
The last thing PASS 2 does is create
two special REM statements as the last
two lines of the new BASIC program.
The first REM contains the name of the
program and the date. The second REM
contains the ID string coded into
line 5 of the PASS 2 program. These
REMs will have invalid line numbers so
they cannot be deleted from the
program.
DISK FILES USED:
PREBASE PREBASE TEST
PASS 2
-----------< end of text >------------